package com.atguigu.flink.sqlfunction;

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
import org.apache.flink.table.catalog.hive.HiveCatalog;

/**
 * Created by Smexy on 2023/3/5
 *
 *  hivecatalog: hive目录，指从hive中读取库和表。
 */
public class Demo7_HiveCatalog
{
    public static void main(String[] args) {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        StreamTableEnvironment tableEnvironment = StreamTableEnvironment.create(env);

        //创建一个hive的目录
        HiveCatalog hiveCatalog = new HiveCatalog("hive", "default", "hiveconf");
        //注册刚刚创建的hive目录
        tableEnvironment.registerCatalog("hivecatalog",hiveCatalog);
        //切换到hive目录，使用
        tableEnvironment.useCatalog("hivecatalog");

        tableEnvironment.sqlQuery("select * from t_order_mt").execute().print();


    }
}
